package leetcode.code0164;

import java.util.Arrays;

import leetcode.IDebug;
import leetcode.helper.HelpDebug;

public class Solution2 implements IDebug {

	public int maximumGap(int[] nums) {
		Arrays.sort(nums);
		int ans = 0;
		for (int i = 1; i < nums.length; i++) {
			ans = Math.max(ans, nums[i] - nums[i - 1]);
		}
		return ans;
	}

	@Override
	public void debug1() {
		HelpDebug.compare(5, this.maximumGap(HelpDebug.str2array3("[4,0,10,5]")));

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub
		HelpDebug.compare(3, this.maximumGap(HelpDebug.str2array3("[3,6,9,1]")));
	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub
		HelpDebug.compare(0, this.maximumGap(HelpDebug.str2array3("[5]")));
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution2 so = new Solution2();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
